<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2015/10/22
 * Time: 8:51
 */
class ActivityskuModel extends BaseModel
{
    private $_table;
    protected $_name = 'activity_sku';
    protected $_isbug = false;

    public function getSampleList($where){
        $this->_table = new self ();
        $db = $this->_table->getAdapter ();

        $sql = $db->select ()->from ( $this->_name)
            ->joinLeft ("activity","$this->_name.activity_id = activity.id")
            ->joinLeft ( "product", "$this->_name.product_sku_id = product.id", array("product_name","product.id as product_id"))
            ->joinLeft ( "product_cates", "product.cate_id = product_cates.id", "cate_name" )
            ->joinLeft ( "product_brands", "product.brand_id = product_brands.id", "brand_name" )
            ->where ( $where )->__toString ();
        if ($this->_isbug == true) {
            echo  __METHOD__.": ".$sql . "<hr/>";
        }
        return $db->fetchAll( $sql );
    }

}